﻿using Vision001.ViewModels;
using SharpVectors.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Vision001.Views
{
    /// <summary>
    /// HomeView.xaml 的交互逻辑
    /// </summary>
    public partial class HomeView : Window
    {
        private bool _isMouseDown = false;
        private Point _mouseDownPos;

        public HomeView(string sn, string Msg)
        {
            InitializeComponent();
            this.DataContext = new HomeViewModel(this, sn, Msg);
            var svgViewbox = new SvgViewbox
            {
                Source = new Uri("pack://application:,,,/Resoures/bojWhite.svg"),
                Stretch = Stretch.Uniform
            };

            Myborder.Background = new VisualBrush { Visual = svgViewbox };
        }

        /// <summary>
        /// 自由拖动窗体，比较简单，就不在后台加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 1 && e.LeftButton == MouseButtonState.Pressed)
            {
                DragMove();
            }
        }

        /// <summary>
        /// 最大化，比较简单，就不在后台加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MaxOrNormal(object sender, RoutedEventArgs e)
        {
            if (WindowState == WindowState.Maximized)
            {
                WindowState = WindowState.Normal;
            }
            else
            {
                WindowState = WindowState.Maximized;
                //InvalidateVisual();
                //UpdateLayout(); // 强制更新布局
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
        }
    }
}